
/*
 * This is the extension activity for a 'SilentAction' activity associated
 * with service '{http://www.pi4soa.org/AuctionHouseBuyer}Broker'
 * and behavior 'main_Broker'. The name of the
 * activity is 'DoTransaction'.
 */
package org.pi4soa.auctionhousebuyer.broker.main_broker;

import org.pi4soa.service.extensions.DefaultActivityExtension;
import org.pi4soa.service.extensions.SilentActivityExtension;
import org.pi4soa.service.extensions.ExtensionContext;
import org.pi4soa.service.ServiceException;
import org.pi4soa.service.DeferProcessingException;

import dk.itu.amds.broker.data.BrokerDB;

/**
 * This class has been autogenerated to implement the custom
 * activity within a service endpoint description.
 */
public class DoTransactionActivity extends DefaultActivityExtension
					implements SilentActivityExtension {

	/**
	 * The constructor for the activity extension.
	 */
	public DoTransactionActivity() {
	}
	
	/**
	 * This method enables an activity extension to
	 * perform activities that are not observable.
	 * 
	 * @param context The context
	 * @exception DeferProcessingException Suspend processing
	 * @exception ServiceException Failed to perform silent action
	 */
	public void process(ExtensionContext context)
				throws DeferProcessingException, ServiceException {

		int buyerBrokerAccountId = Integer.parseInt(context.getVariable("buyerBrokerAccountId").toString());
		int sellerBrokerAccountId = Integer.parseInt(context.getVariable("sellerBrokerAccountId").toString());
		float transferAmount = Float.parseFloat(context.getVariable("transferAmount").toString());
		
		BrokerDB.transfer(buyerBrokerAccountId, sellerBrokerAccountId, transferAmount);
		
		// TODO: Add code to perform tasks relevant to
		// the Silent Action.
		
	}
}	